home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1997 August / Macworld (1997-08).dmg / Serious Demos / Crimson Demo / Crimson Demos / ListBox Demo / README < prev   
Encoding:
Text File  |  1997-06-17  |  3.7 KB  |  72 lines  |  [TEXT/ttxt]

  1.                                                                 ListBox Demo
  2.  
  3. The ListBox demo is intended to demonstrate the ease with which a ListBox can be manipulated under program control using the Crimson Basic Development System.
  4.  
  5. Double Click on the ListDemo Icon (this is the Project file) and view the Project Window.
  6.  
  7. Under the 'Common Code' heading can be seen a single entry named 'Initial'. The Initial code module is executed immediately after the application is started and is intended, among other things, to set up the applications Menu, and display the initial Form.
  8.  
  9. Double Click on 'Initial' to view the program code.
  10.  
  11. Initial  Module.
  12.  
  13. Two Global variables are defined to hold the values of the menu id for the 'File' menu and the menu item id for the 'Quit' menu item.
  14.  
  15. The InitMenu command creates a new Menu Bar for the application containing the Apple menu only.
  16.  
  17. The AddMenu function adds a Menu to the Menu Bar named 'File'.
  18.  
  19. The AddmenuItem function adds a Menu Item to the 'File" menu named 'Quit' with a keyboard equivalent of 'Q'.
  20.  
  21. The Initial form 'DemoForm' is then opened and displayed.
  22. From here on all further processing is handled by events which are automatically generated from within the application.
  23.  
  24. Click the Close Box on the Edit Window to return to the project Window.
  25.  
  26. Click on 'DemoForm' under the 'Form' heading and a module named 'MainProg' will appear under the 'Form Code' heading. 
  27. Form Code program modules are ones which are directly related to a particular form and selecting that form will display the related program modules. Common Code modules, as one would expect, are ones that are not related to any one form.
  28.  
  29. Double Click on 'DemoForm' to bring up the Form Designer.
  30.  
  31. The form contains a ListBox, a CheckBox, and Editable Text field and 3 Buttons.
  32. Double Click on each of these (and the Window) to view the Initial properties which have been set .
  33.  
  34. Return to the Project Window by selecting the Close Box on the Form Designer Window.
  35.  
  36. Click on 'DemoForm' to reveal the 'MainProg' program module then Double Click on this to view the code.
  37.  
  38. MainProg Module
  39.  
  40. The MainProg module contains a set of Event Handling routines. These routines are called automatically by the system in response to user actions involving the mouse.
  41.  
  42. DemoForm.OnMenu
  43.  
  44. This procedure is invoked whenever the user selects a menu item (and the 'DemoForm' Window is the Active one). The QuitBtn.Click routine is called. Selecting this menu item is the equivalent of clicking the 'Quit' Button.
  45.  
  46. QuitBtn.Click
  47.  
  48. This procedure is invoked whenever the user Clicks the 'Quit' Button. It simply Closes the Window and Ends the program.
  49.  
  50. AddBtn.Click
  51.  
  52. This procedure is invoked when the user Clicks the "Add" Button.
  53. The statement 'InputValue=DemoForm.InputBox.Value' get the string which the user has typed into the InputBox Editable Text field and places it in the InputValue variable.
  54. The 'DemoForm.ListBox.InsertRow(1,InputValue)' statement inserts a row, berfore row 1 into the ListBox.
  55.  
  56. DelBtn.Click
  57.  
  58. This routine loops through the rows in the ListBox searching for ones which are selected (using the GetSelected method) and deletes each of them in turn.
  59.  
  60. CheckBox.MouseDown
  61.  
  62. This procedure is invoked whenever the mouse button is depressed and it is over the 'Multiple Selection' CheckBox. The value of the CheckBox (On/Off or True/False) is automatically toggled by the system.
  63. The statement 'State=DemoForm.CheckBox.Value' returns the True/False value of the CheckBox.
  64. The 'MultiSel' property of the ListBox is then set to this value.
  65.  
  66. Return to the main Project window and select Application / Build Application from the menu. The application will be built and an executable module created. (use LBDemo as the name of the executable module.
  67.  
  68. Quit the development system and Double Click on the LBDemo application to see this program in action.
  69.  
  70.  
  71.  
  72.